{% extends 'base.html' %}
{% block css %}
<link href="/static/css/dataTables.bootstrap.min.css" rel="stylesheet">
{% endblock %}
{% block content %}
<div class="right_col" role="main">
    <div class="">
        <div class="clearfix"></div>
        <div class="row">
            <div class="col-md-12 col-sm-12 col-xs-12">
                <div class="x_panel">
                    <div class="x_title">
                        <div class="loading"></div>
                        <h2>vpn用户管理/账号增加 </h2>
                        <div class="clearfix"></div>
                    </div>
                    <div class="x_content" style="padding-top:10px;border:none">

                    <form class="form-horizontal" id="form">
                                   <div class="form-group">
                                    <label class="col-sm-2 control-label">用户名*</label>
                                    <div class="col-sm-6">
                                        <input  class="form-control" id="user_name" required="required" placeholder="请输入英文字符">
                                    </div>
                                </div>

                                <div class="form-group">
                                    <label  class="col-sm-2 control-label">名称</label>
                                    <div class="col-sm-6">
                                        <input  class="form-control" id="name_alias" placeholder="中文名字">
                                    </div>
                                </div>

                                <div class="form-group">
                                    <label  class="col-sm-2 control-label">密码*</label>
                                    <div class="col-sm-6">
                                        <input type="password" class="form-control" id="user_password" required="required" placeholder="请输入密码">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label  class="col-sm-2 control-label">邮箱</label>
                                    <div class="col-sm-6">
                                        <input class="form-control " id="user_email" placeholder="请输入邮箱">
                                    </div>
                                </div>
                                 <div class="form-group">
                                    <label  class="col-sm-2 control-label" >是否激活</label>
                                    <div class="col-sm-6">
                                        <input type="checkbox" value="1" class="col-lg-1" id="is_active">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <div class="col-sm-offset-7 col-sm-1">
                                        <button type="button" class="btn btn-primary" id="submit-btn">提交</button>
                                    </div>
                                </div>

                    </form>
                    <div class="form-group" style="color: #46b8da">
                        result:
                        <span id="result_show" >

                        </span>
                    </div>





                    </div>
                </div>
            </div>
        </div>
    </div>
</div>



{% endblock %}
{% block js %}
<script src="/static/js/jquery.dataTables.min.js"></script>
<script src="/static/js/dataTables.bootstrap.min.js"></script>
<script src="/static/js/display_select.js"></script>

    <script>
       $(document).ready(function(){
            $("#submit-btn").click(function () {
                var user_name = $("#user_name").val();
                var name_alias = $("#name_alias").val();
                var user_password = $("#user_password").val();
                var user_email = $("#user_email").val();
                var is_active = $("#is_active").val();
                params = {
                    "user_name":user_name,
                    "name_alias":name_alias,
                    "user_password":user_password,
                    "user_email":user_email,
                    "is_active":is_active


                }
                 $.ajax({
                type: "POST",
                url: "/op/vpn_add",
                data: params,
                success: function (res) {
                    if (res.status == 0) {
                        window.location.href = "/op/vpn_manger";
                    }else {
                         $("#result_show").html(res.msg);
                    }


                },
		        error: function (XMLHttpRequest, textStatus, errorThrown) {
			        alert(errorThrown);
                 }
            });

        });
    });


    </script>


{% endblock %}

